package com.cty.LinkedList;

import org.junit.Test;

public class SingleLinkedListDemo {
    @Test
    public void test() {
        heroNode node1 = new heroNode(1, "宋江", "及时雨");
        heroNode node2 = new heroNode(2, "卢俊义", "玉麒麟");
        heroNode node3 = new heroNode(3, "吴用", "智多星");
        heroNode node4 = new heroNode(4, "林冲", "豹子头");
        SingleLinkedList singleLinkedList = new SingleLinkedList();
        heroNode node5 = new heroNode(2, "xiaolu", "玉麒麟~~");
        singleLinkedList.addByOrder(node1);
        singleLinkedList.addByOrder(node4);
        singleLinkedList.addByOrder(node2);
        singleLinkedList.addByOrder(node3);
        System.out.println("链表有限节点的个数");
        System.out.println(question01.size(singleLinkedList.getHead()));
        System.out.println("获取链表倒数第二个节点");
        System.out.println(question02.getReciprocalNode(singleLinkedList.getHead(), 2));
        System.out.println("获取链表第5个节点");
        System.out.println(question02.getReciprocalNode(singleLinkedList.getHead(), 5));
        //反转前链表
        System.out.println("反转前链表~~");
        singleLinkedList.list();
        //反向遍历
        System.out.println("反向遍历链表~~");
        question04.ReversePrint(singleLinkedList.getHead());
        singleLinkedList.list();
        System.out.println("链表未反转~~~");
        //反转节点
        System.out.println("反转后链表~~~");
        question03.invert(singleLinkedList.getHead());
        singleLinkedList.list();
        //测试问题5中的方法
        SingleLinkedList singleLinkedList1 = new SingleLinkedList();
        SingleLinkedList singleLinkedList2 = new SingleLinkedList();
        heroNode Node2 = new heroNode(2, "02", "02");
        heroNode Node5 = new heroNode(5, "05", "05");
        heroNode Node9 = new heroNode(9, "09", "09");
        singleLinkedList1.add(Node2);
        singleLinkedList1.add(Node5);
        singleLinkedList1.add(Node9);
        System.out.println("链表一~~");
        singleLinkedList1.list();
        heroNode Node1 = new heroNode(1, "02", "02");
        heroNode Node4 = new heroNode(4, "05", "05");
        heroNode Node7 = new heroNode(7, "09", "09");
        singleLinkedList2.add(Node1);
        singleLinkedList2.add(Node4);
        singleLinkedList2.add(Node7);
        System.out.println("链表二~~~");
        singleLinkedList2.list();
        System.out.println("合并后的遍历~~~");
        SingleLinkedList merge = question05.merge(singleLinkedList1, singleLinkedList2);
        merge.list();
    }
}
